<?php
/*******************************************************************************

    FinalsClub.org is a platform for students and faculty to collaborate
    and share their knowledge with the world.

    Copyright (C) 2009  Andrew Magliozzi
 
    This file is a part of FinalsClub.org.

    FinalsClub.org is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
    To contact FinalsClub.org, send an email to info@finalsclub.org, or
    send mail to Finals Club, c/o Veritas Tutors, 1132 Massachusetts Avenue,
    Cambridge, MA 02138.

*******************************************************************************/

class ChangePasswordResetForm extends sfForm
{
  public function setup() {
	$this->setWidgets(array('password' => new sfWidgetFormInputPassword()));
	$this->setWidgets(array('confirm_password' => new sfWidgetFormInputPassword()));
	
  	$this->setWidgets(array('rid' => new sfWidgetFormInputHidden()));
  	$this->setWidgets(array('token' => new sfWidgetFormInputHidden()));
  }

  public function configure()
  { 
  	$this->widgetSchema['password'] = new sfWidgetFormInputPassword();
	$this->widgetSchema['confirm_password'] = new sfWidgetFormInputPassword();
	
	$this->widgetSchema['rid'] = new sfWidgetFormInputHidden();
	$this->widgetSchema['token'] = new sfWidgetFormInputHidden();
	
	$this->widgetSchema->setNameFormat('password_change[%s]');
	
	$this->validatorSchema['password'] = new sfValidatorString(array('required' => true), 
		array('required' => 'Password is required'));
		
	$this->validatorSchema['confirm_password'] = new sfValidatorString(array('required' => true), 
		array('required' => 'Confirm password is required'));    
	
	// make sure password fields match
	$this->validatorSchema->setPostValidator(
	  new sfValidatorSchemaCompare('password', '==', 'confirm_password', array(),
	    array('invalid' => 'The passwords do not match')
	  )
	);
	
	$this->validatorSchema->setOption('allow_extra_fields', true);
	$this->validatorSchema->setOption('filter_extra_fields', false);
  }

}